package com.zm.oes.mapper;

import com.zm.oes.entity.Admin;
import com.zm.oes.entity.Student;
import com.zm.oes.entity.Teacher;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface LoginMapper {

    /**
     * 该方法用于管理员用户的登录验证
     * 通过@Select注解指定了SQL查询语句，查询管理员表中与给定用户名（adminId）和密码（pwd）匹配的记录
     * 返回类型为Admin对象
     */
    @Select("select adminId,adminName,sex,tel,email,cardId,role from `admin` where adminId = #{username} and pwd = #{password}")
    public Admin adminLogin(@Param("username") Integer username, @Param("password") String password);

    /**
     * 该方法用于教师用户的登录验证。
     * 过@Select注解指定了SQL查询语句，查询教师表中与给定用户名（teacherId）和密码（pwd）匹配的记录
     * 返回类型为Teacher对象。
     */
    @Select("select teacherId,teacherName,institute,sex,tel,email,cardId," +
            "type,role from teacher where teacherId = #{username} and pwd = #{password}")
    public Teacher teacherLogin(@Param("username") Integer username, @Param("password") String password);

    /**
     * 该方法用于学生用户的登录验证
     * 通过@Select注解指定了SQL查询语句，查询学生表中与给定用户名（studentId）和密码（pwd）匹配的记录
     * 返回类型为Student对象。
     */
    @Select("select studentId,studentName,grade,major,clazz,institute,tel," +
            "email,cardId,sex,role from student where studentId = #{username} and pwd = #{password}")
    public Student studentLogin(@Param("username") Integer username, @Param("password") String password);
}
